package br.ufrgs.tst.ga.operators;

import java.security.InvalidParameterException;

import junit.framework.Assert;

import org.junit.Before;
import org.junit.Test;

import br.ufrgs.ga.operators.CrossoverOperator;
import br.ufrgs.ga.operators.CrossoverOperator.CrossoverType;

public class TestCrossoverOperator {

	/**
	 * Class under test.
	 */
	private CrossoverOperator crossoverOperator;

	@Before
	public void setUp() {
		this.crossoverOperator = new CrossoverOperator(CrossoverType.Head, 3);
	}

	@Test
	public void executeTest() {
		String dnaStrand1 = "012340";
		String dnaStrand2 = "014560";
		String newDnaStrand = crossoverOperator.execute(dnaStrand1, dnaStrand2);
		Assert.assertEquals("012560", newDnaStrand);
		
		boolean exceptionHasBeenThrown = false;
		try {
			crossoverOperator.execute(dnaStrand1, null);
		} catch (InvalidParameterException e) {
			exceptionHasBeenThrown = true;
		}
		
		Assert.assertTrue(exceptionHasBeenThrown);
	}
}
